

#ifndef PB_H__
#define PB_H__

#include <stdint.h>
#include <string.h>
#include <stdbool.h>

#include "pb.def.h"

#include "app_util.h"



typedef uint32_t (*pb_tx_data_handle_t)(const uint8_t * data, uint16_t size );

typedef int (*pb_tx_array_handle_t)(const uint8_array_t * p_data_array, uint32_t count);  

bool pb_check_packet_integrity( pb_msg_t * p_msg_head);

bool pb_check_flag_has_crypto( pb_msg_t * p_msg);

pb_stream_t pb_stream_from_buffer( uint8_t* data, uint32_t size); 

int pb_assemble_rx_msg( pb_msg_t * p_msg, const uint8_t* data_in, uint16_t size );

bool pb_assemble_tx_msg0( pb_msg_t * p_msg, pb_tx_data_handle_t cb);

bool pb_assemble_tx_msg( pb_msg_t * p_msg, pb_tx_array_handle_t cb);

bool pb_assemble_tx_data(uint8_t* data, uint16_t size, uint8_t flag, pb_tx_array_handle_t cb);

void pb_assemble_data_header(uint8_t* data, uint16_t size, uint8_t flag, pb_msg_t * p_msg);

void pb_assemble_data_add_header(uint8_t* data, pb_msg_t * p_msg);

void pb_assemble_data_add_header_default(uint8_t *data, uint16_t len );

void pb_message_abort( pb_msg_t * msg );

//bool pb_assemble_negative_response(pb_ret_code_t err, pb_tx_array_handle_t cb);

#endif 
